package com.kevin.designpattern.factory_method.demo1;

import java.util.Arrays;

public class Sorter {
    public static void sort(Cat[] arr) {

        for (int i = 0; i < arr.length - 1; i++) {
            int minPos = i;
            for (int j = i + 1; j < arr.length; j++) {
                minPos = arr[j].compareTo(arr[minPos]) == -1 ? j : minPos;
            }

            System.out.println("minPos = " + minPos);

            swap(arr, i, minPos);
            System.out.println("数组经过第" + i + "次循环后，数组的内容");
            System.out.println(Arrays.toString(arr));
        }

    }

    static void swap(Cat[] arr, int i, int j) {
        Cat temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
